/**
 * Created by Administrator on 2017/9/7.
 */
;(function ($) {

    function mySelectBox(data, setting) {
        $nowObj = this;
        var s = '<ul class="box-defaut-ul"></ul>';//
        var $box = $(s);
        $box.addClass(setting.boxClass);
        if ($box.children('li').length==0){
            $.each(data, function () {
                console.log(this);
                var tmpS = '<li data-id="' + this[setting.k] + '">' + this[setting.v] + '</li>';
                $box.append(tmpS);
            });
            $nowObj.after($box);
            console.log($box);
        } else {
            $box.show();
        }
        // $nowObj.blur(function(){
        //     $box.hide();
        // })
        $box.children('li').click(function(){

            // console.log("aa")
            $nowObj.val($(this).html());
            $box.hide();
        })
        $box.append('<li>关闭</li>');
        $box.find('li:last').click(function(){
            $box.hide();
        })

    }

    $.fn.mySelectBox = mySelectBox;

})(jQuery)